<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var setZeroes = function (matrix) {
      var rows = {}
      var column = {}
      for (var i = 0; i < matrix.length; i++)
        for (var j = 0; j < matrix[0].length; j++) {
          if (matrix[i][j] == 0) {
            rows[i] = false
            column[j] = false
          }
        }
      for (var i = 0; i < matrix.length; i++)
        for (var j = 0; j < matrix[0].length; j++) {
          if ((rows[i] == false) || (column[j] == false))
            matrix[i][j] = 0
        }
      return matrix
    };
    console.log(setZeroes([[1, 1, 1], [1, 0, 1], [1, 1, 1]]))
  </script>
</body>

</html>